package yoyu.animationtest;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.airbnb.lottie.LottieAnimationView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

    LottieAnimationView animationView;
    Button button;
    MyWorldView myWorldView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        animationView = (LottieAnimationView) findViewById(R.id.animation_view);
        myWorldView = (MyWorldView) findViewById(R.id.my_worldview);
        myWorldView.setOnClickListener(this);
        button = (Button) findViewById(R.id.button);
        button.setOnClickListener(this);
        animationView.setAnimation("glow.json");
        animationView.loop(true);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.button:
                myWorldView.clickAnimation();
            break;
            case R.id.my_worldview:
                myWorldView.runAnimation();
                break;
        }

    }
}
